package com.zx.练习题._2022面试题;

import java.util.Arrays;

public class Demo10 {

    public static void main(String[] args) {
        int[] nums1 = {1, 2, 3, 0, 0, 0};
        int[] nums2 = {2, 5, 6};

        int n1 = 0;
        int n2 = 0;

        while (n1 < nums1.length && n2 < nums2.length) {
            if (nums1[n1] == 0) {
                nums1[n1] = nums2[n2];
                n2++;
                continue;
            }
            if (nums1[n1] <= nums2[n2]) {
                n1++;
                continue;
            }

            for (int i = nums1.length - 1; i >= n1 + 1; i--) {
                nums1[i] = nums1[i - 1];
            }
            nums1[n1] = nums2[n2];
            n2++;
        }
        System.out.println(Arrays.toString(nums1));
    }
}
